//
//  BaseTabBarController.swift
//  jingxin
//
//  Created by Yuki on 2020/8/5.
//  Copyright © 2020 Zl. All rights reserved.
//

import UIKit

class BaseTabBarController: UITabBarController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        /**  找到tabBar  **/
        let myTabBar = UITabBar.appearance();
        myTabBar.tintColor = UIColor.white;
        myTabBar.barTintColor = UIColor.black;//tabbar背景色
        /**  添加控制器  **/
        addChiledControlers();
    }
    
    /// 添加子控制器
    private func addChiledControlers(){
        /**  添加Home  **/
        setChildController(with:HomeController(), with:"tab_home");
        /**  添加我的  **/
        setChildController(with: MineController(), with: "tab_mine");
    }
    
    
    /// 设置tabbar
    /// - Parameters:
    ///   - controller: 控制器
    ///   - imageName: 图片名称
    private func setChildController(with controller:BaseController ,with imageName:String){
        controller.tabBarItem.image = UIImage(named: imageName + "_nor");
        controller.tabBarItem.selectedImage = UIImage(named: imageName + "_sel");
        //这里可以修改图片的大小
        controller.tabBarItem.imageInsets = UIEdgeInsets(top: 10, left: 0, bottom: -10, right: 0);
        addChild(BaseNavigationController(rootViewController: controller));
        
    }
    
    
    
}
